﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
using ComApp;

namespace AndroidApp
{
    public class ThisApp : IDisposable
    {
        private static ThisApp instance;
        public static ThisApp Instance
        {
            get
            {
                return instance ?? (instance = new ThisApp());
            }
        }


        public void Start()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }

        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;
            FileLog.Instance.Log(exception);
        }

        private ViewManager viewManager;
        public ViewManager ViewManager
        {
            get
            {
                return this.viewManager ?? (this.viewManager = new ViewManager());
            }
        }


        private AppDeploy appDeploy;
        public AppDeploy AppDeploy
        {
            get
            {
                return this.appDeploy ?? (this.appDeploy = new AppDeploy());
            }
        }

        public void Close()
        {
            AppUnity.Instance.Close();
            //HttpService.Instance.DeleteAllFileCache();
        }

        public void Dispose()
        {
            this.Close();
        }

    }
}
